<?php

/** @see Zend_View_Helper_Abstract */
require_once 'Zend/View/Helper/Abstract.php';

/**
 * Helper for retrieving the BaseUrl
 */
class My_View_Helper_PlayPlaylist extends Zend_View_Helper_Abstract
{

    /**
     * Generates flash widget which plays list of song based on grooveshark song IDs
     *
     * @param array $songIDs Grooveshark song IDs
     * @param bool $autostart
     * @param int $width
     * @param int $height
     * @param string $style
     * @return string
     */
    public function PlayPlaylist($songIDs, $autostart = false, $width = 400, $height = 400, $style = 'metal', $bbg = '000000', $bt = 'FFFFFF', $bfg = '666666')
    {

        $songIDs = implode(',', $songIDs);


        $autostart = (int) $autostart;

        $xhtml = '';

        $xhtml .= '<object width="' . $width . '" height="' . $height . '">';
        $xhtml .= '<param name="movie" value="http://listen.grooveshark.com/widget.swf"></param>';
        $xhtml .= '<param name="wmode" value="window"></param>';
        $xhtml .= '<param name="allowScriptAccess" value="always"></param>';
        $xhtml .= '<param name="flashvars" value="hostname=cowbell.grooveshark.com&amp;songIDs=' . $songIDs . '&amp;style=' . $style . '&amp;p=' . $autostart . '&amp;bbg=' . $bbg . '&amp;bt=' . $bt . '&amp;bfg=' . $bfg . '"></param>';
        $xhtml .= '<embed src="http://listen.grooveshark.com/widget.swf" type="application/x-shockwave-flash" width="' . $width . '" height="' . $height . '"';
        $xhtml .= 'flashvars="hostname=cowbell.grooveshark.com&amp;songIDs=' . $songIDs . '&amp;style=' . $style . '&amp;p=' . $autostart . '&amp;bbg=' . $bbg . '&amp;bt=' . $bt . '&amp;bfg=' . $bfg . '" allowScriptAccess="always" wmode="window"></embed>';
        $xhtml .= '</object>';

        return $xhtml;
    }

}
